gsMISCAboutLoad "About WFingerD", "WFingerD v1.1", "This daemon application services TCP Finger clients (typically port 79). You can select any file you wish to be your machine's finger response."
End Sub
Sub NetClient_OnError (iErrorNumber As Integer)
StatusBar = NetClient.ErrorMessage
Debug.Print "NetClient:" & NetClient.ErrorMessage
Close #miFile
NetClient.Connect = False
End Sub
Sub NetClient_OnRecv ()
Dim sTemp As String
Dim iPlace As Integer
On Error GoTo ErrorHandler
If NetClient.RecvCount = 0 Then Exit Sub
sTemp = NetClient
While Right$(sTemp, 1) = Chr$(13) Or Right$(sTemp, 1) = Chr$(10)
NetClient = "Oops, I've forgotten what I'm supposed to tell you... Try again later!"
NetClient.Connect = False
Exit Sub
End If
miFile = FreeFile
Open msFingerFile For Input As #miFile
mlLength = LOF(miFile) - 1
SendFingerFile
Exit Sub
ErrorHandler:
Select Case Err
Case 62:
Resume Next
Case 53:
NetClient = "Tell my owner that his WFingerD file is missing!" & Chr$(13) & Chr$(10)
NetClient.Connect = False
Exit Sub
End Select
NetClient = Chr$(13) & Chr$(10) & "Oops, Tell my owner that I had an error" & Str$(Err) & " (" & Error$(Err) & ") on line " & Str$(Erl) & " in WFingerD. Thanks!" & Chr$(13) & Chr$(10)
If miFile <> 0 Then Close #miFile
NetClient.Connect = False
Exit Sub
End Sub
Sub NetClient_OnSend ()
Dim sTemp As String
SendFingerFile
End Sub
Sub NetServer_OnAccept (Socket As Integer, PeerAddr As String, RemotePort As Integer)
CMDialog.Flags = OFN_FILEMUSTEXIST Or OFN_PATHMUSTEXIST Or OFN_READONLY
CMDialog.Action = 1
If Err <> 32755 Then
msFingerFile = CMDialog.Filename
PanelFilename.Caption = msFingerFile
Ini.Filename = "wfingerd.ini"
Ini.Section = "Configuration"
Ini.Entry = "FingerFile"
Ini.Value = msFingerFile
End If
End Sub
Sub SendFingerFile ()
Dim sTemp As String
On Error GoTo ErrorHandler2
If Not EOF(miFile) Then
If mlLength > CHUNK_SIZE Then
sTemp = Input$(CHUNK_SIZE, miFile)
NetClient = sTemp
mlLength = mlLength - CHUNK_SIZE
Else
sTemp = Input$(mlLength, miFile)
If sTemp = "" Then
Close #miFile
NetClient.Connect = False
Exit Sub
End If
NetClient = sTemp
End If
Else
Close #miFile
NetClient.Connect = False
End If
Exit Sub
ErrorHandler2:
Select Case Err
Case 62:
Resume Next
End Select
NetClient = Chr$(13) + Chr$(10) + "Oops, Tell my owner that I had an error" + Str$(Err) + " (" + Error$(Err) + ") on line " + Str$(Erl) + " in WFingerD. Thanks!" + Chr$(13) + Chr$(10)